#include <iostream>
#include <windows.h>
#include <dokan.h>

void TestCreateFile() {
    // 单元测试：创建文件
    const std::wstring fileName = L"F:/test.txt";
    HANDLE hFile = CreateFile(fileName.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    if (hFile != INVALID_HANDLE_VALUE) {
        std::wcout << L"CreateFile test passed." << std::endl;
        CloseHandle(hFile);
    } else {
        std::wcout << L"CreateFile test failed." << std::endl;
    }
}

void TestWriteFile() {
    // 单元测试：写入文件
    const std::wstring fileName = L"F:/test.txt";
    HANDLE hFile = CreateFile(fileName.c_str(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    if (hFile != INVALID_HANDLE_VALUE) {
        const char* data = "Hello, Dokan!";
        DWORD bytesWritten;
        WriteFile(hFile, data, (DWORD)strlen(data), &bytesWritten, NULL);
        CloseHandle(hFile);
        std::wcout << L"WriteFile test passed." << std::endl;
    } else {
        std::wcout << L"WriteFile test failed." << std::endl;
    }
}